cmake_minimum_required (VERSION 3.10)
project(SwTask)

# 头文件目录
include_directories("${PROJECT_SOURCE_DIR}/..")

#找到所有含有main函数的c文件，保存在mains里
file(
    GLOB_RECURSE mains RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "${CMAKE_CURRENT_SOURCE_DIR}/SwChildTest.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/SwTaskTest.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/SwTimTest.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/SwErrorTest.c"
    "${CMAKE_CURRENT_SOURCE_DIR}/vSwTest.c"
)

#循环遍历每个含main的文件，分别编译生成exe文件
foreach(mainfile IN LISTS mains)
    # Get file name without directory
    get_filename_component(mainname ${mainfile} NAME_WE)
    add_executable(${mainname} ${mainfile})
endforeach()

